package com.cn.project;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;

/**
 * @author he_ls
 * @since 2024/11/1 16:57
 **/
public class T03_JsonNull {
    public static void main(String[] args) {
        // {data:"["xx","yy"]",total:4}
        // {data:"['xx','yy']",total:4}
        // {data:"[]",total:4}
        // {data:,total:4}
        String str = "{data:'',total:4}";
        JSONObject jsonObject = new JSONObject(str);
        JSONArray data = jsonObject.getJSONArray("data");
        if (data == null) { // 空数组[]时，不会进入
            System.out.println("data is null");
        }
        if (data.isEmpty()) {
            System.out.println("data is empty");
        }
        if (data == null || data.isEmpty()) {
            System.out.println("没有返回值。。。。");
        }
        System.out.println(data);

    }
}
